// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import Tool from "../framework/Tool";

const {ccclass, property} = cc._decorator;

@ccclass
export default class XFManager extends cc.Component {

    public static GetScene():  XFManager {
        if ( XFManager._inScene == null) {
            XFManager._inScene = new  XFManager();
        }
        return  XFManager._inScene;
    }
    static _inScene = null;

    toMenuScene(){
        cc.director.loadScene("main");
    }
    fingerGuessing(){
        Tool.loadPrefab("xf/fingerGuessing/fingerguessing",(res)=>{
            let view = cc.instantiate(res);
            view.position = cc.v3(0,0,0);
            view.parent = cc.find("Canvas");
        })
    }

    drunkery(){
        Tool.loadPrefab("xf/drunkery/drunkery",(res)=>{
            let view = cc.instantiate(res);
            view.position = cc.v3(0,0,0);
            view.parent = cc.find("Canvas");
        })
    }

    private times = 1;
    public  starTime()
    {
        this.times = 1;
        this.schedule(this.addTime,5);
    }

    public addTime()
    {
        this.times++;
    }

    public  closeTime()
    {
        this.unschedule(this.addTime);
        return this.times*5;
    }


    // update (dt) {}
}
